<?php


namespace app\api\model;


class Order extends BaseModel
{
    protected $hidden = ['user_id','delete_time','update_time'];
    public function getSnapItemsAttr($value){
        if(empty($value)){
            return null;
        }
        return json_decode($value);
    }
    public function getSnapAddressAttr($value){
        if(empty($value)){
            return null;
        }
        return json_decode($value);
    }

    /**
     * @param     $uid
     * @param int $page
     * @param int $size
     *
     * @return \think\Paginator
     * @throws \think\db\exception\DbException
     */
    public static function getSummaryByUser($uid,$page=1,$size=1): \think\Paginator
    {

        $datas =  self::where('user_id','=',$uid)
            ->order('create_time desc')
            ->paginate([
            'list_rows'=>$size,
            'page'=>$page
        ],true);
//        $datas = self::where('user_id','=',$uid)->select();
        return $datas;
    }
}